#!/bin/bash
echo "Usage: $0 passwd input out [-d]"
set -e

[[ "$#" != "3" && "$#" != "4" ]] && exit

echo "passwd: $1"
KEY=$(echo -n "$1" | sha256sum)
KEY=${KEY:0:64}
echo "KEY: $KEY"

echo "in: $2"
echo "out: $3"
echo "addition: $4"

echo "processing..."
openssl enc -aes-256-cbc -nosalt $4 -K "$KEY" -iv "00000000000000000000000000000000" -in "$2" -out "$3"

